package com.lft.com.oilgas.mapper;

import com.lft.com.oilgas.entity.Merchant;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author tyqw
 * @since 2024-09-10
 */
public interface MerchantMapper extends BaseMapper<Merchant> {
    //查询商户的信息
    @Select("SELECT " +
            "merchant.id, merchant.address, merchant.contacts, " +
            "merchant.contact_phone, merchant.characteristic, " +
            "merchant.merchant_id, merchant.integral, " +
            "id_card.front, id_card.opposite, merchant.business_license, " +
            "merchant.legal_person, " +
            "merchant.openan_account,  " +
            "merchant.other_qualifications, merchant.merchant_type, " +
            "merchant.audit_status, merchant.user_id, " +
            "merchant.business_term, merchant.merchant_name," +
            "merchant.collaboration_status, merchant.review_time, accounts.imgs," +
            "business.image, accounts.status AS accounts_status, business.audit_status AS business_status," +
            "id_card.status AS id_card_status " +
            "FROM merchant " +
            "LEFT JOIN id_card ON merchant.legal_person = id_card.id " +
            "LEFT JOIN accounts ON merchant.openan_account = accounts.id " +
            "LEFT JOIN business ON merchant.business_license = business.id " +
            "WHERE (merchant.contacts LIKE CONCAT('%', #{tiaojian}, '%') OR #{tiaojian} = '') " +
            "LIMIT #{offset}, #{row_count}")
    List<Map<String, Object>> selectAllMerchantsWithLegalPersonName(Map map);

}
